import { ApiPropertyOptional } from '@nestjs/swagger';

export class Pagination {
  @ApiPropertyOptional({ description: '当前页数' })
  current: number;
  @ApiPropertyOptional({ description: '总记录数' })
  total: number;
  @ApiPropertyOptional({ description: '每页记录数' })
  pagesize: number;

  getCurrent(): number {
    return this.current === 0 ? 1 : this.current;
  }

  setCurrent(current): void {
    this.current = current === 0 ? 1 : current;
  }
  getTotal() {
    return this.total;
  }

  setTotal(total) {
    this.total = total;
  }

  getPagesize() {
    return this.pagesize == 0 ? 10 : this.pagesize;
  }

  setPagesize(pagesize) {
    this.pagesize = pagesize == 0 ? 10 : pagesize;
  }
}
